#ifndef _YADCOMB_FRACTION_H_
#define _YADCOMB_FRACTION_H_

#include <iostream>

inline int YADCOMB_gcd(int n1, int n2)
{
	if (n1 < 0) n1 = -n1;
	if (n2 < 0) n2 = -n2;

	for (;;)
	{
		if (!n1) return n2;
		n2 %= n1;
		if (!n2) return n1;
		n1 %= n2;
	}
}

inline int YADCOMB_lcm(int n1, int n2)
{
	const int gcd = YADCOMB_gcd(n1, n2);
	return gcd ? (n1 / gcd * n2) : 0;
}

//template<class T> 

class Fraction
{
	int numerator;
	int denominator;

public:
	Fraction(int n = 0, int d = 1);

	int get_numerator() const;

	int get_denominator() const;

	Fraction operator+(const Fraction& rhs) const;

	Fraction operator-(const Fraction& rhs) const;

	Fraction operator*(const Fraction& rhs) const;

	Fraction operator/(const Fraction& rhs) const;
};

Fraction operator-(const Fraction& rhs);

std::ostream& operator<<(std::ostream& os, const Fraction& f);

#endif
